﻿using System;
using System.Windows.Input;

namespace PasswordProvider.ViewModel.Framework
{
    /// <summary>
    /// CommandViewModel: View model for an ICommand. Inherits from VisualViewModel and adds
    /// new properties: ICommand Command, bool IsDefault.
    /// </summary>
    public class CommandViewModel : VisualViewModel
    {
        #region Construction

        internal CommandViewModel(string displayName, ICommand command)
            : this(displayName, null, false, command)
        {
        }

        internal CommandViewModel(string displayName, string toolTip, ICommand command)
            : this(displayName, toolTip, false, command)
        {            
        }

        internal CommandViewModel(string displayName, string toolTip, bool isDefault, ICommand command)
            : base(displayName, toolTip)
        {
            if (command == null)
                throw new ArgumentNullException("command");
            
            this.Command = command;
            _isDefault = isDefault;
        }

        #endregion // Construction

        #region Public Properties

        /// <summary>
        /// The Command
        /// </summary>
        public ICommand Command 
        {
            get { return _command; }
            set { SetPropertyValue(value, ref _command, "Command"); }
        } private ICommand _command;

        /// <summary>
        /// IsDefault property
        /// </summary>
        public bool IsDefault 
        {
            get { return _isDefault; }
            set { SetPropertyValue(value, ref _isDefault, "IsDefault"); }
        } bool _isDefault;

        #endregion
    }
}
